# 定义员工管理 类
import requests


class IhrmEmpApi:
    # 定义 添加员工的方法
    @classmethod
    def add_emp(cls, header, req_data):
        resp = requests.post(url="https://ihrm-java.itheima.net/api/sys/user",
                             headers=header,
                             json=req_data)
        return resp



# 定义 查询员工的方法
    @classmethod
    def query_emp(cls,emp_id,header):
        resp = requests.get(url="https://ihrm-java.itheima.net/api/sys/user/" + emp_id,
                            headers=header)
        return resp
# 定义 修改员工的方法
    @classmethod
    def modify_emp(cls,emp_id,header,req_data):
        resp = requests.put( url="https://ihrm-java.itheima.net/api/sys/user/" + emp_id,
                            headers=header, json = req_data )
        return resp

# 定义 删除员工的方法
    @classmethod
    def delete_emp(cls,emp_id,header):
        resp = requests.delete( url="https://ihrm-java.itheima.net/api/sys/user/" + emp_id,
                            headers=header )
        return resp

if __name__ == '__main__':
    req_header = {"Authorization": "eea8529f-a849-41c1-b9c7-a8af4a18bdc7"}
    add_json = {
        "username": "麻辣烫",
        "mobile": "13911122298",
        "workNumber": "9527"
    }
    response = IhrmEmpApi.add_emp(req_header,add_json)
    print(f"添加员工:{response}")
    # response = IhrmEmpApi.query_emp("1980277515909804032",req_header)
    # print(f"查询员工:{response}")
    # modify_json = {"username": "麻辣烫不烫"}
    # response = IhrmEmpApi.modify_emp("1980277515909804032",req_header,modify_json)
    # print(f"修改员工:{response}")
    # response = IhrmEmpApi.delete_emp("1980277515909804032",req_header)
    # print(f"删除员工:{response}")
